﻿using SPSAndong.Comm;
using SPSAndong.Handle;
using Sunny.UI;
using System;
using System.Windows.Forms;

namespace SPSAndong.Forms
{
    public partial class FrmWorkOutTime : UIPage
    {
        bool isLoad = true;      //判断窗体是否首次加载
        SPSAndongHandler sPSAndongHandler;      
        public FrmWorkOutTime()
        {
            InitializeComponent();
        }

        private void FrmWorkOutTime_Load(object sender, EventArgs e)
        {
            //如果窗体已经加载过则不重新加载
            if (!isLoad)
                return;
            isLoad = false;
            UpdateUI();
            sPSAndongHandler = SPSAndongHandler.getInstance();
            sPSAndongHandler.OnOuttimeChanged += OuttimeChanged_Event;
        }

        private void OuttimeChanged_Event()
        {
            UpdateUI();
        }

        /// <summary>
        /// 更新UI
        /// </summary>
        private void UpdateUI()
        {
            this.Invoke(new MethodInvoker(() =>
            {
                buttonouttime.Text = GolbalVariable.Overtime.ToString();
            }));
        }
    }
}
